<template>
  <el-form ref="loginForm" class="login-form" :model="form">
    <el-form-item>
      <el-input v-model="form.phone" auto-complete="off" placeholder="请输入PHONE"></el-input>
    </el-form-item>
    <el-form-item>
      <el-input v-model="form.code" auto-complete="off" placeholder="请输入验证码">
        <template slot="append">
          <span class="msg-text" :class="[{display:msgKey}]">发送验证码</span>
        </template>
      </el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit" class="login-submit">登录</el-button>
    </el-form-item>
  </el-form>
</template>

<script>

  export default {
    name: "code-login",
    data() {
      return {
        form: {
          phone: '',
          code: '',
        }
      }
    },
    methods : {
      onSubmit : function() {
        this.loading = true
        this.$store.dispatch("LoginByUser", this.form).then(res => {
          this.loading = false
          this.$router.push({ path: '/'});
        }).catch(() => {
          this.loading = false
        })
      }
    }
  }
</script>

<style scoped>

</style>